<?php

class QuanLyController extends BaseController {

    public function index($type = null) {
        switch ($type) {
            case 'dscanbo':
            case 'themcanbo':
                $canbo = new CanBoController();
                return ($type == 'dscanbo') ? $canbo->index() : $canbo->add();
                
            case 'dschucvu':
            case 'themchucvu':
                $chucvu = new ChucVuController();
                return ($type == 'dschucvu') ? $chucvu->index() : $chucvu->add();
                
            case 'dschucdanh':
            case 'themchucdanh':
                $chucdanh = new ChucDanhController();
                return ($type == 'dschucdanh') ? $chucdanh->index() : $chucdanh->add();
                
            case 'dscoso':
            case 'themcoso':
                $coso = new CoSoThanhTraController();
                return ($type == 'dscoso') ? $coso->index() : $coso->add();
                
            case 'dsdoankt':
            case 'themdoankt':
                $doankt = new DoanKiemTraController();
                return ($type == 'dsdoankt') ? $doankt->index() : $doankt->add();
                
            case 'dscuockt':
            case 'themcuockt':
                $cuockt = new CuocKiemTraController();
                return ($type == 'dscuockt') ? $cuockt->index() : $cuockt->add();
                
            case 'themtv':
                $doankt = new DoanKiemTraController();
                return $doankt->addMemBer();
                
            case 'dsnam':
            case 'themnam':
                $nam = new NamController();
                return ($type == 'dsnam') ? $nam->index() : $nam->add();
                
            case 'doimatkhau':
                $doimatkhau = new HomeController();
                return $doimatkhau->getChangePassword();
                
            case 'tuychon':
                $tuychon = new HomeController();
                return $tuychon->getCauHinh();
                
            case 'export':
                $export = new HomeController();
                return $export->getExport();
                
            case 'dshosott':
                $hoso = new DonController();
                return $hoso->index();
            
            case 'list_cstt':
                $coso = new CoSoThanhTraController();
                return $coso->getList();
                
            case 'tienhanhtt':
                $tienhanhkt = new ChiTietCuocKiemTraController();
                return $tienhanhkt->index();
                
            case 'thongke':
                return View::make('profiles.thongke')
                            ->with("title", "Thống kê chung");
                
            default:
                return View::make('home.index')
                                ->with("title", "Hệ thống quản lý hồ sơ thanh tra thuế");
        }
    }
    
    public function add($type) {
        switch ($type) {
            case 'bieumau':
                $bieumau = new BieuMauController();
                return $bieumau->add();
            default:
                return $this->index();
        }
    }

    public function show($type) {
        switch ($type) {
            case 'dscanbo':
                $canbo = new CanBoController();
                return $canbo->edit();
                
            case 'dschucvu':
                $chucvu = new ChucVuController();
                return $chucvu->edit();
                
            case 'dschucdanh':
                $chucdanh = new ChucDanhController();
                return $chucdanh->edit();
                
            case 'dscoso':
                $cstt = new CoSoThanhTraController();
                return $cstt->edit();
            
            case 'dsdoankt':
                $doankt = new DoanKiemTraController();
                return $doankt->edit();
                
            case 'dshosott':
                $hoso = new DonController();
                return $hoso->viewDon();
                
            case 'dscuockt':
                $cuockt = new CuocKiemTraController();
                return $cuockt->edit();
                
            default:
                return $this->index();
        }
    }

    public function search($type) {
        switch ($type) {
            case 'dscanbo':
            case 'timcanbo':
                $canbo = new CanBoController();
                return ($type === 'dscanbo') ? $canbo->index() : $canbo->search();
            case 'dsdoankt':
            case 'timdoankt':
                $doankt = new DoanKiemTraController();
                return ($type === 'dsdoankt') ? $doankt->index() : $doankt->search();
            case 'dscoso':
            case 'timcoso':
                $coso = new CoSoThanhTraController();
                return ($type === 'dscoso') ? $coso->index() : $coso->search();
            case 'timctcosodoan':
                $timctcs = new DoanThanhTraController();
                return $timctcs->search();
            case 'timctcoso':
                $timctcs = new ChiTietCoSoController();
                return $timctcs->search();
            case 'dsdontt':
                $hoso = new DonController();
                return ($type === 'dsdontt') ? $hoso->index() : $hoso->search();
            case 'dscuockt':
                $cuockt = new CuocKiemTraController();
                return ($type === 'dscuockt') ? $cuockt->index() : $cuockt->search();
            default:
                return $this->index();
        }
    }

    public function save($type) {
        switch ($type) {
            case 'dscanbo':
                $canbo = new CanBoController();
                return $canbo->save();
            case 'dschucvu':
                $chucvu = new ChucVuController();
                return $chucvu->save();
            case 'dschucdanh':
                $chucdanh = new ChucDanhController();
                return $chucdanh->save();
            case 'dscoso':
                $coso = new CoSoThanhTraController();
                return $coso->save();
            case 'dsdoankt':
                $doankt = new DoanKiemTraController();
                return $doankt->save();
            case 'dsnam':
                $nam = new NamController();
                return $nam->save();
            case 'doantt':
                $doantt = new DoanKiemTraController();
                return $doantt->save();
            case 'dscuockt':
                $cuoctt = new CuocKiemTraController();
                return $cuoctt->save();
            case 'tv':
                $ct_dkt = new ChiTietDoanKiemTraController();
                return $ct_dkt->save();
            default:
                return $this->index();
        }
    }

    public function ajax($type) {
        switch ($type) {
            case 'doantt':
                $doantt = new DoanThanhTraController();
                return $doantt->save();
            default:
                return $this->index();
        }
    }

    public function store($type) {
        switch ($type) {
            case 'dscanbo':
                $canbo = new CanBoController();
                return $canbo->store();
            case 'dschucvu':
                $chucvu = new ChucVuController();
                return $chucvu->store();
            case 'dschucdanh':
                $chucdanh = new ChucDanhController();
                return $chucdanh->store();
            case 'dsdoankt':
                $doankt = new DoanKiemTraController();
                return $doankt->store();
            case 'doimatkhau':
                $doimatkhau = new HomeController();
                return $doimatkhau->postChangePassword();
            case 'dscoso':
                $cs = new CoSoThanhTraController();
                return $cs->store();
            default:
                return $this->index();
        }
    }

    public function remove($type) {
        switch ($type) {
            case 'dscanbo':
                $canbo = new CanBoController();
                return $canbo->remove();
            case 'dschucvu':
                $chucvu = new ChucVuController();
                return $chucvu->remove();
                
            case 'dschucdanh':
                $chucdanh = new ChucDanhController();
                return $chucdanh->remove();
            case 'dscoso':
                $cstt = new CoSoThanhTraController();
                return $cstt->remove();
            case 'dscoso':
                $cstt = new CoSoThanhTraController();
                return $cstt->remove();
            case 'dsdoankt':
                $doankt = new DoanKiemTraController();
                return $doankt->remove();
            case 'dsnam':
                $nam = new NamController();
                return $nam->remove();
            case 'doantt':
                $doantt = new DoanThanhTraController();
                return $doantt->remove();
            default:
                return $this->index();
        }
    }

}
